function varargout = mapAverager2p0(varargin)
% MAPAVERAGER2P0 M-file for mapAverager2p0.fig
%      MAPAVERAGER2P0, by itself, creates a new MAPAVERAGER2P0 or raises the existing
%      singleton*.
%
%      H = MAPAVERAGER2P0 returns the handle to a new MAPAVERAGER2P0 or the handle to
%      the existing singleton*.
%
%      MAPAVERAGER2P0('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in MAPAVERAGER2P0.M with the given input arguments.
%
%      MAPAVERAGER2P0('Property','Value',...) creates a new MAPAVERAGER2P0 or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before mapAverager2p0_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to mapAverager2p0_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help mapAverager2p0

% Last Modified by GUIDE v2.5 25-Jul-2006 06:56:36

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @mapAverager2p0_OpeningFcn, ...
                   'gui_OutputFcn',  @mapAverager2p0_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin & isstr(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before mapAverager2p0 is made visible.
function mapAverager2p0_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to mapAverager2p0 (see VARARGIN)

% Choose default command line output for mapAverager2p0
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes mapAverager2p0 wait for user response (see UIRESUME)
% uiwait(handles.figure1);

handles = autoFillROI(handles);
guidata(hObject, handles);


% --- Outputs from this function are returned to the command line.
function varargout = mapAverager2p0_OutputFcn(hObject, eventdata, handles)
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;

% ======================== FILE STUFF & misc ========================

% --- Executes during object creation, after setting all properties.
function currentFile_CreateFcn(hObject, eventdata, handles)
% hObject    handle to currentFile (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
%function currentFile_Callback(hObject, eventdata, handles)
% hObject    handle to currentFile (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of currentFile as text
%        str2double(get(hObject,'String')) returns contents of currentFile as a double


% --- Executes on button press in selectFile.
function selectFile_Callback(hObject, eventdata, handles)
% hObject    handle to selectFile (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
try
    handles = selectFile(handles);
    handles = updateCurrentGroup(handles);
    guidata(hObject, handles);
catch
end

% --- Executes on button press in newFile.
function newFile_Callback(hObject, eventdata, handles)
% hObject    handle to newFile (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
try
    handles = newFile(handles);
    handles = updateCurrentGroup(handles);
    guidata(hObject, handles);
catch
end

% ======================== GROUP LIST STUFF ========================

% --- Executes during object creation, after setting all properties.
function groupList_CreateFcn(hObject, eventdata, handles)
% hObject    handle to groupList (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: listbox controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on selection change in groupList.
function groupList_Callback(hObject, eventdata, handles)
% hObject    handle to groupList (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns groupList contents as cell array
%        contents{get(hObject,'Value')} returns selected item from groupList
handles = updateLists(handles);
handles = updateCurrentGroup(handles);
guidata(hObject, handles);


% --- Executes on button press in renameGroup.
function renameGroup_Callback(hObject, eventdata, handles)
% hObject    handle to renameGroup (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles = renameGroup(handles);
handles = updateCurrentGroup(handles);
guidata(hObject, handles);


% --- Executes on button press in addGroup.
function addGroup_Callback(hObject, eventdata, handles)
% hObject    handle to addGroup (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles = addGroup(handles);
handles = updateCurrentGroup(handles);
guidata(hObject, handles);


% --- Executes on button press in deleteSelectedGroup.
function deleteSelectedGroup_Callback(hObject, eventdata, handles)
% hObject    handle to deleteSelectedGroup (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles = deleteGroup(handles);
handles = updateCurrentGroup(handles);
guidata(hObject, handles);


% --- Executes on button press in moveGroupUp.
function moveGroupUp_Callback(hObject, eventdata, handles)
% hObject    handle to moveGroupUp (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles = moveGroupUpDown(handles, 'up');
guidata(hObject, handles);


% --- Executes on button press in moveGroupDown.
function moveGroupDown_Callback(hObject, eventdata, handles)
% hObject    handle to moveGroupDown (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles = moveGroupUpDown(handles, 'down');
guidata(hObject, handles);


% ======================== CELL LIST STUFF ========================

% --- Executes during object creation, after setting all properties.
function cellList_CreateFcn(hObject, eventdata, handles)
% hObject    handle to cellList (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: listbox controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on selection change in cellList.
function cellList_Callback(hObject, eventdata, handles)
% hObject    handle to cellList (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns cellList contents as cell array
%        contents{get(hObject,'Value')} returns selected item from cellList


% --- Executes on button press in renameCell.
function renameCell_Callback(hObject, eventdata, handles)
% hObject    handle to renameCell (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles = renameCell(handles);
guidata(hObject, handles);


% --- Executes on button press in addCells.
function addCells_Callback(hObject, eventdata, handles)
% hObject    handle to addCells (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles = addCells(handles);
guidata(hObject, handles);


% --- Executes on button press in deleteCell.
function deleteCell_Callback(hObject, eventdata, handles)
% hObject    handle to deleteCell (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles = deleteCell(handles);
guidata(hObject, handles);


% --- Executes on button press in moveCellUp.
function moveCellUp_Callback(hObject, eventdata, handles)
% hObject    handle to moveCellUp (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles = moveCellUpDown(handles, 'up');
guidata(hObject, handles);


% --- Executes on button press in moveCellDown.
function moveCellDown_Callback(hObject, eventdata, handles)
% hObject    handle to moveCellDown (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles = moveCellUpDown(handles, 'down');
guidata(hObject, handles);


% ======================== ANALYSIS ========================

% --- Executes during object creation, after setting all properties.
function selectMapType_CreateFcn(hObject, eventdata, handles)
% hObject    handle to selectMapType (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on selection change in selectMapType.
function selectMapType_Callback(hObject, eventdata, handles)
% hObject    handle to selectMapType (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns selectMapType contents as cell array
%        contents{get(hObject,'Value')} returns selected item from selectMapType



% --- Executes on button press in mapAvgList.
function mapAvgList_Callback(hObject, eventdata, handles)
% hObject    handle to mapAvgList (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
try
    figFlag = 1;
    handles = mapAvgFromCellListB(handles, figFlag);
    guidata(hObject, handles);
catch
    error(lasterr);
end


% --- Executes on button press in avgEP.
function avgEP_Callback(hObject, eventdata, handles)
% hObject    handle to avgEP (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles = excitationProfileAnalysisB(handles);
guidata(hObject, handles);



% -------- ROI: --------------

% --- Executes on button press in autoFillROI.
function autoFillROI_Callback(hObject, eventdata, handles)
% hObject    handle to autoFillROI (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles = autoFillROI(handles);
guidata(hObject, handles);


% --- Executes on button press in setAsDefault.
function setAsDefault_Callback(hObject, eventdata, handles)
% hObject    handle to setAsDefault (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles = setAsDefault(handles);
guidata(hObject, handles);



% COLUMN AVG:

% --- Executes on button press in colAvg.
function colAvg_Callback(hObject, eventdata, handles)
% hObject    handle to colAvg (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
try
    handles = mapAvgFromCellListB(handles, 0);
    handles.analysis.mapAverager.ROI.option = 'col';
    handles = mapROImeans(handles, 1);
    handles = generateGroupData(handles);
    guidata(hObject, handles);
catch
end


% --- Executes during object creation, after setting all properties.
function colROIfirstRow_CreateFcn(hObject, eventdata, handles)
% hObject    handle to colROIfirstRow (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function colROIfirstRow_Callback(hObject, eventdata, handles)
% hObject    handle to colROIfirstRow (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of colROIfirstRow as text
%        str2double(get(hObject,'String')) returns contents of colROIfirstRow as a double
handles.analysis.mapAverager.ROI.colROIfirstRow = str2double(get(hObject,'String'));
guidata(hObject, handles);


% --- Executes during object creation, after setting all properties.
function colROIlastRow_CreateFcn(hObject, eventdata, handles)
% hObject    handle to colROIlastRow (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function colROIlastRow_Callback(hObject, eventdata, handles)
% hObject    handle to colROIlastRow (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of colROIlastRow as text
%        str2double(get(hObject,'String')) returns contents of colROIlastRow as a double
handles.analysis.mapAverager.ROI.colROIlastRow = str2double(get(hObject,'String'));
guidata(hObject, handles);


% --- Executes during object creation, after setting all properties.
function colROIfirstCol_CreateFcn(hObject, eventdata, handles)
% hObject    handle to colROIfirstCol (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function colROIfirstCol_Callback(hObject, eventdata, handles)
% hObject    handle to colROIfirstCol (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of colROIfirstCol as text
%        str2double(get(hObject,'String')) returns contents of colROIfirstCol as a double
handles.analysis.mapAverager.ROI.colROIfirstCol = str2double(get(hObject,'String'));
guidata(hObject, handles);


% --- Executes during object creation, after setting all properties.
function colROIlastCol_CreateFcn(hObject, eventdata, handles)
% hObject    handle to colROIlastCol (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function colROIlastCol_Callback(hObject, eventdata, handles)
% hObject    handle to colROIlastCol (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of colROIlastCol as text
%        str2double(get(hObject,'String')) returns contents of colROIlastCol as a double
handles.analysis.mapAverager.ROI.colROIlastCol = str2double(get(hObject,'String'));
guidata(hObject, handles);


% ROW AVG:

% --- Executes on button press in rowAvg.
function rowAvg_Callback(hObject, eventdata, handles)
% hObject    handle to rowAvg (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
try
    handles = mapAvgFromCellListB(handles, 0);
    handles.analysis.mapAverager.ROI.option = 'row';
    handles = mapROImeans(handles, 1);
    handles = generateGroupData(handles);
    guidata(hObject, handles);
catch
end


% --- Executes during object creation, after setting all properties.
function rowROIfirstRow_CreateFcn(hObject, eventdata, handles)
% hObject    handle to rowROIfirstRow (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function rowROIfirstRow_Callback(hObject, eventdata, handles)
% hObject    handle to rowROIfirstRow (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.analysis.mapAverager.ROI.rowROIfirstRow = str2double(get(hObject,'String'));
guidata(hObject, handles);


% --- Executes during object creation, after setting all properties.
function rowROIlastRow_CreateFcn(hObject, eventdata, handles)
% hObject    handle to rowROIlastRow (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function rowROIlastRow_Callback(hObject, eventdata, handles)
% hObject    handle to rowROIlastRow (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.analysis.mapAverager.ROI.rowROIlastRow = str2double(get(hObject,'String'));
guidata(hObject, handles);


% --- Executes during object creation, after setting all properties.
function rowROIfirstCol_CreateFcn(hObject, eventdata, handles)
% hObject    handle to rowROIfirstCol (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function rowROIfirstCol_Callback(hObject, eventdata, handles)
% hObject    handle to rowROIfirstCol (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.analysis.mapAverager.ROI.rowROIfirstCol = str2double(get(hObject,'String'));
guidata(hObject, handles);


% --- Executes during object creation, after setting all properties.
function rowROIlastCol_CreateFcn(hObject, eventdata, handles)
% hObject    handle to rowROIlastCol (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function rowROIlastCol_Callback(hObject, eventdata, handles)
% hObject    handle to rowROIlastCol (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.analysis.mapAverager.ROI.rowROIlastCol = str2double(get(hObject,'String'));
guidata(hObject, handles);


% REGION AVG:

% --- Executes on button press in regionAvg.
function regionAvg_Callback(hObject, eventdata, handles)
% hObject    handle to regionAvg (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
try
    handles = mapAvgFromCellListB(handles, 0);
    handles.analysis.mapAverager.ROI.option = 'all';
    handles = mapROImeans(handles, 1);
    handles = generateGroupData(handles);
    guidata(hObject, handles);
catch
end


% --- Executes during object creation, after setting all properties.
function allROIfirstRow_CreateFcn(hObject, eventdata, handles)
% hObject    handle to allROIfirstRow (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function allROIfirstRow_Callback(hObject, eventdata, handles)
% hObject    handle to allROIfirstRow (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.analysis.mapAverager.ROI.allROIfirstRow = str2double(get(hObject,'String'));
guidata(hObject, handles);


% --- Executes during object creation, after setting all properties.
function allROIlastRow_CreateFcn(hObject, eventdata, handles)
% hObject    handle to allROIlastRow (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function allROIlastRow_Callback(hObject, eventdata, handles)
% hObject    handle to allROIlastRow (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.analysis.mapAverager.ROI.allROIlastRow = str2double(get(hObject,'String'));
guidata(hObject, handles);


% --- Executes during object creation, after setting all properties.
function allROIfirstCol_CreateFcn(hObject, eventdata, handles)
% hObject    handle to allROIfirstCol (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function allROIfirstCol_Callback(hObject, eventdata, handles)
% hObject    handle to allROIfirstCol (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.analysis.mapAverager.ROI.allROIfirstCol = str2double(get(hObject,'String'));
guidata(hObject, handles);


% --- Executes during object creation, after setting all properties.
function allROIlastCol_CreateFcn(hObject, eventdata, handles)
% hObject    handle to allROIlastCol (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function allROIlastCol_Callback(hObject, eventdata, handles)
% hObject    handle to allROIlastCol (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.analysis.mapAverager.ROI.allROIlastCol = str2double(get(hObject,'String'));
guidata(hObject, handles);


% ======================== 2-GROUP COMPARISON ========================

% --- Executes on button press in groupAselect.
function groupAselect_Callback(hObject, eventdata, handles)
% hObject    handle to groupAselect (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
set(handles.groupAcurrent, 'String', handles.analysis.mapAverager.currentGroup);
handles.analysis.mapAverager.groupA.groupName = handles.analysis.mapAverager.currentGroup;
handles.analysis.mapAverager.groupA.groupVal = get(handles.groupList, 'Value');
guidata(hObject, handles);


% --- Executes on button press in groupBselect.
function groupBselect_Callback(hObject, eventdata, handles)
% hObject    handle to groupBselect (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
set(handles.groupBcurrent, 'String', handles.analysis.mapAverager.currentGroup);
handles.analysis.mapAverager.groupB.groupName = handles.analysis.mapAverager.currentGroup;
handles.analysis.mapAverager.groupB.groupVal = get(handles.groupList, 'Value');
guidata(hObject, handles);


% --- Executes during object creation, after setting all properties.
function groupAcurrent_CreateFcn(hObject, eventdata, handles)
% hObject    handle to groupAcurrent (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function groupAcurrent_Callback(hObject, eventdata, handles)
% hObject    handle to groupAcurrent (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes during object creation, after setting all properties.
function groupBcurrent_CreateFcn(hObject, eventdata, handles)
% hObject    handle to groupBcurrent (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function groupBcurrent_Callback(hObject, eventdata, handles)
% hObject    handle to groupBcurrent (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in compareGroups.
function compareGroups_Callback(hObject, eventdata, handles)
% hObject    handle to compareGroups (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
try
    handles = compareGroups(handles);
catch
    error(lasterr);
end
guidata(hObject, handles);


% --- Executes on button press in flipSignCheck.
function flipSignCheck_Callback(hObject, eventdata, handles)
% hObject    handle to flipSignCheck (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes during object creation, after setting all properties.
function testType_CreateFcn(hObject, eventdata, handles)
% hObject    handle to testType (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on selection change in testType.
function testType_Callback(hObject, eventdata, handles)
% hObject    handle to testType (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% ======================== HELP ========================

function helpOnMapAverager_Callback(hObject, eventdata, handles)
% hObject    handle to helpOnMapAverager (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
type helpMapAverager;



% ======================== MISC ========================

% --- Executes on button press in handles2ws.
function handles2ws_Callback(hObject, eventdata, handles)
% hObject    handle to handles2ws (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
assignin('base', 'handles', handles);
disp('Handles variable created (or over-written) in workspace');



% --- Executes on mouse press over figure background.
function figure1_ButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to figure1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
%
% this is an empty callback!


% ======================== PARAMETRIC ANALYSIS ========================
function parameter1name_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
%
function parameter1name_Callback(hObject, eventdata, handles)
% Hints: get(hObject,'String') returns contents of parameter1name as text
%        str2double(get(hObject,'String')) returns contents of parameter1name as a double


function parameter1toWS_Callback(hObject, eventdata, handles)
paramStr = get(handles.parameter1name,'String');
if isempty(paramStr)
    disp('Parameter name missing.')
    return
else
    handles = loadParameter(paramStr, handles); 
    guidata(hObject, handles);
end
handles.analysis.mapAverager.parameter1Name = handles.analysis.mapAverager.currentParameterName;
handles.analysis.mapAverager.parameter1Val = handles.analysis.mapAverager.currentParameterVal;
% send it to the workspace
assignin('base', handles.analysis.mapAverager.currentParameterName, handles.analysis.mapAverager.currentParameterVal);
% show it in the command window
evalin('base', handles.analysis.mapAverager.currentParameterName);



function parameter2name_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
%
function parameter2name_Callback(hObject, eventdata, handles)


function parameter2toWS_Callback(hObject, eventdata, handles)
paramStr = get(handles.parameter2name,'String');
if isempty(paramStr)
    disp('Parameter name missing.')
    return
else
    handles = loadParameter(paramStr, handles); 
    guidata(hObject, handles);
end
handles.analysis.mapAverager.parameter2Name = handles.analysis.mapAverager.currentParameterName;
handles.analysis.mapAverager.parameter2Val = handles.analysis.mapAverager.currentParameterVal;
% send it to the workspace
assignin('base', handles.analysis.mapAverager.currentParameterName, handles.analysis.mapAverager.currentParameterVal);
% show it in the command window
evalin('base', handles.analysis.mapAverager.currentParameterName);



function plot1vs2_Callback(hObject, eventdata, handles)
handles = plot1vs2(handles);
guidata(hObject, handles);


function plotAvsB_Callback(hObject, eventdata, handles)
handles = plot1vsROI3(handles);
guidata(hObject, handles);


